package ar.com.photo_admin.taglibs

import ar.com.photo_admin.domain.PresentationPhoto;
import ar.com.photo_admin.domain.User

class GlobalGraphicElementsTagLib {

	static namespace = "global"
	
	final INTERVAL = 2000
	
	def springSecurityService

	
	def userService
	
	def carousel = { attrs, body ->
		
		def presentationLinks = []
		
		presentationLinks = userService.getPresentationPhotosUrls(springSecurityService?.currentUser?.id).toList()
		
		//desordeno las fotos		
		Collections.shuffle(presentationLinks)
		
		out << """ <div id="photoZoomContainer" class="photoZoomContainer">""";			
		
		// Comienzo Imágenes		
		presentationLinks.eachWithIndex { presentationLink, i ->
			if ( i < 5){
				out << """ <div class="wrap">""";
				out << """<a href="${presentationLink.albumUrl}">""";
				out << """<img  src="${presentationLink.photoUrl}" alt="image">""";
				out << """</a>""";
				out << """</div>""";
			}
	
						
		}
		
		// Fin Imágenes
		

		out << """</div>""";
		
	}
	
	
}
